/*=====================================================
 Copyright (C) ETERNAL<iqstar@ms24.hinet.net>
 URL : http://www.et99.net

请仔细阅读以下许可协议。当您使用本软体，您将自动成为本协议的一方并受到本协议的约束。

软体和文档受到台湾及中国大陆著作权法及国际条约的保护。您不得：
a)营利、出租或者出借软体或文档的任何部分。
b)反向工程、分解、反编译或者企图察看软体的源代码作为商业用途。
c)修改或者改变软体，或者与其他程式结合。

许可人保留软体及文档的所有权利和权益。您不能通过本许可协定获得软体的任何所有权和知识产权。
===================================================== */

//####### fight begin #######
function datechk(s, b) {
    var foot = parent.foot.document.f1;
    var error = "";
    if (b.f_count.value > 40) {
        error = "战斗回合数不能大于" + f_count;
    }
    foot.subplace.value = "";
    switch (true) {
        case b.a_type[0].checked:
            foot.act.value = b.act1.value;
            foot.temp_id.value = 0;
            // foot.subplace.value = b.subplace.value || "";
            break;
        case b.a_type[1].checked:
            foot.act.value = b.act2.value;
            foot.temp_id.value = 1;
            if (b.act2.value == "1000") {
                if (!confirm("挑战冠军需付500元费用")) {
                    error = "结束挑战";
                }
            }
            if (b.act2.value == "1001") {
                if (dfoot.menu.towho.value == "") {
                    error = "没有选择对象不能PK";
                }
            }
            break;
        case b.a_type[2].checked:
            foot.act.value = b.act3.value;
            foot.temp_id.value = 2;
//			foot.subplace.value=b.sp_subplace.value || "";
            break;
    }
    if (foot.act.value == "") {
        error = "请选择场地";
    }
    if (error != "") {
        alert(error);
    } else {
        if (b.a_mode[0].checked == true) {
            foot.temp_id2.value = 1;
        }
        if (b.a_mode[1].checked == true) {
            foot.temp_id2.value = 2;
        }
        p_sat_name = b.sat_name.value;
        Sookie("wog_set_cookie", foot.temp_id.value + "," + foot.act.value + "," + foot.temp_id2.value + "," + b.act_area.value + "," + foot.subplace.value);
        f_count = b.f_count.value;
        f_hp = b.f_hp.value;
        f_sp = b.f_sp.value;
        f_escape_hp = b.escape_hp.value;
        hotel_hp = b.hotel_hp.value;
        hotel_sp = b.hotel_sp.value;
        foot.f.value = "fire";
        foot.action = "wog_fight.php";
        foot.at_type.value = s;
        foot.sat_name.value = b.sat_name.value;
        foot.towho.value = dfoot.menu.towho.value;
        foot.temp_id3.value = b.f_count.value;
        foot.temp_id4.value = b.f_hp.value;
        foot.temp_id8.value = b.f_sp.value;
        foot.temp_id5.value = b.escape_hp.value;
        foot.temp_id6.value = b.hotel_hp.value;
        foot.temp_id7.value = b.hotel_sp.value;
        from_copy(foot, parent.foot.document.f2);
        foot.submit();
    }
};

function fight_fast() {
    var foot = parent.foot.document.f1;
    f = parent.wog_view.document;
    from_copy(parent.foot.document.f2, foot);
    foot.action = "wog_fight.php";
    foot.submit();
    UI.set_target.getElementById("con_fight").innerHTML = '<font color="#000000">冒险旅程</font>';
};

function from_copy(f1, f2) {
    f2.f.value = f1.f.value;
    f2.act.value = f1.act.value;
    f2.pay_id.value = f1.pay_id.value;
    f2.temp_id.value = f1.temp_id.value;
    f2.temp_id2.value = f1.temp_id2.value;
    f2.temp_id3.value = f1.temp_id3.value;
    f2.temp_id4.value = f1.temp_id4.value;
    f2.temp_id5.value = f1.temp_id5.value;
    f2.temp_id6.value = f1.temp_id6.value;
    f2.temp_id7.value = f1.temp_id7.value;
    f2.temp_id8.value = f1.temp_id8.value;
    f2.at_type.value = f1.at_type.value;
    f2.sat_name.value = f1.sat_name.value;
    f2.subplace.value = f1.subplace.value;
};

function change_mission(s, b) {
    if (b.a_type) {
        b.a_type[s].checked = true;
    }
};

function select_area(num, s) {
    var place = s.act1;
    var first = null;
    place.options.length = 0;
    place.selectedIndex = 0;
    switch (parseInt(num, 10)) {
        case 1:
            place.options[0] = new Option("[1] 中央平原", "1");
            place.options[1] = new Option("[3] 黑暗沼泽", "3");
            place.options[2] = new Option("[7] 王者之路", "7");
            place.options[3] = new Option("[13] 水晶之间", "13");
            first = 1;
            break;
        case 2:
            place.options[0] = new Option("[2] 试炼洞窟", "2");
            place.options[1] = new Option("[8] 幻兽森林", "8");
            place.options[2] = new Option("[12] 天空之城", "12");
            place.options[3] = new Option("[15] 最果之岛", "15");
            first = 2;
            break;
        case 3:
            place.options[0] = new Option("[4] 迷雾森林", "4");
            place.options[1] = new Option("[11] 无渊洞窟", "11");
            place.options[2] = new Option("[16] 冷峰寒地", "16");
            place.options[3] = new Option("[9] 星河异界", "9");
            first = 4;
            break;
        case 4:
            place.options[0] = new Option("[10] 灼热荒漠", "10");
            place.options[1] = new Option("[5] 古代遗迹", "5");
            place.options[2] = new Option("[6] 久远战场", "6");
            place.options[3] = new Option("[14] 失落古船", "14");
            place.options[4] = new Option("[21] 血之魔域", "21");
            first = 10;
            break;
        default:
            place.options[0] = new Option("请选择场所", "");
            break;
    }
    place.options[0].selected = true;
    setSubplace(first, s.subplace);
};

/**
 * 选择子地图
 * @param id
 * @param subplace
 */
function setSubplace(id, subplace) {
    if (subplace) {
        subplace.options.length = 0;
        subplace.options[0] = new Option("不限定", "");
        if (!isNaN(id) && sec[id]) {
            var list = sec[id];
            for (var i = 1, item; item === list[i]; i++) {
                subplace.options[i] = new Option(`[${item[1]}]` + item[0], item[1]);
            }
        }
        subplace.selectedIndex = 0;
    }
};

/**
 * 战斗页面
 */
function ad_view() {
    let dungeon = '';
    for (var temp_p in sp_sec) {
        dungeon += `<option value="${temp_p}">${sp_sec[temp_p][0]}</option>`;
    }
    w_c(`<form name="f1"><div>
    <div class="fight-ready-box  d-flex  align-content-stretch justify-content-center">
        <label id="fightToMap" data-a_type="1" class="fight-to-map pos-r fight-category status-view-container box-border-gradient selected">
           <input type="radio"  data-parent="" name="a_type" value="1" checked style="opacity: 0;position:absolute;left: 0;top: 0;"> 
                <p class="font-size-18 mb-10 text-center">冒险修行</p>
                ${temp_country}
                <select name="act1" class="game-select mt-10" onchange="parent.change_mission(0,this.form);parent.setSubplace(this.options[this.selectedIndex].value,'');">
                    <option value="" selected>选择场所</option>
                </select>
            <!--        <select name="subplace" onchange="parent.change_mission(0,this.form);"><option value="" selected="selected">不限定</option></select>-->
        </label>
        <label id="fightToPk" data-a_type="2"class="fight-to-pk fight-category status-view-container box-border-gradient">
                <input type="radio"  name="a_type" value="2" style="opacity: 0;position:absolute;left: 0;top: 0;">
                <p class="font-size-18 mb-10 text-center">武斗竞技</p>
                <select name="act2" class="game-select" onChange="parent.change_mission(1,this.form);">
                    <option value="" SELECTED>选择模式</option>
                    <option value="1000">挑战冠军</option>
                    <option value="1001"> PK 挑战</option>
                </select>
                <div class="mt-10">
                <a href="#"
                   onclick="parent.mouse_xy(event.x||event.pageX,event.y||event.pageY);parent.act_click('pk','view');"
                   target="mission">PK设定</a>
                   </div>
        </label>
        <label id="fightToDungeon"data-a_type="3"  class="fight-to-dungeon fight-category status-view-container box-border-gradient">
                <input type="radio" name="a_type" value="3" style="opacity: 0;position:absolute;left: 0;top: 0;">
                <p class="font-size-18 mb-10 text-center">禁区挑战</p>
                <select name="act3"  class="game-select"  onChange="parent.change_mission(2,this.form);">
                    <option value="" SELECTED>选择地点</option>
                    ${dungeon}
                </select>
        </label>
    </div>
    <div class="d-flex flex-col align-items-center mt-20">
    <div class="d-flex align-items-stretch">
        <label class="box-border-gold-bg d-block p-10 " style="width:200px;">
            <div class="font-weight-bold font-size-18 text-white"><input  type="radio" name="a_mode" value="1" class="mr-10">快速战斗</div>
            <p class="font-size-12 text-grey">直接给出战斗结果，高效简洁地刷怪</p>
        </label>
        <label class="box-border-gold-bg d-block p-10 ml-10" style="width:200px;">
            <div class="font-weight-bold font-size-18 text-white"><input  type="radio" name="a_mode" value="2" class="mr-10">一般模式</div>
            <p class="text-grey">按回合显示战斗日子，技能、伤害直观，方便分析对局</p>
        </label>
        <label class="box-border-gold-bg d-block p-10 ml-10" style="width:200px;">
            <div class="font-weight-bold font-size-18 text-white"><input id="autofightAMode" type="radio" name="a_mode" value="1" class="mr-10">自动战斗</div>
            <p class="text-grey">用"快速战斗"模式为您自动冒险，解放双手</p>
        </label>
    </div>
        <div class="d-flex align-items-center mt-10">
            <button type="button" class="brick-btn brick-btn-sm" onclick="parent.datechk(1,document.forms[0]);parent.AUTO_FIGHT=document.getElementById('autofightAMode').checked?'ready':'stop';parent.autoFight()"><div class="d-flex align-items-center justify-content-center"><img src="./../ex_img/wog_infinity/btn/act_mode_1.png" class="brick-btn-icon" alt=""> 物理攻击</div></button>
            <button type="button" class="brick-btn brick-btn-sm brick-btn-green" onclick="parent.datechk(2,document.forms[0]);parent.AUTO_FIGHT=document.getElementById('autofightAMode').checked?'ready':'stop';parent.autoFight()"><div class="d-flex align-items-center justify-content-center"><img src="./../ex_img/wog_infinity/btn/act_mode_2.png" class="brick-btn-icon" alt=""> 魔法攻击</div></button>
        </div>
<div class="my-10"><a href="javascript:;" onclick="toggleFightSetting()">战斗设置(点击展开/关闭)</a></div>
        <div id="fightSetting" class="box-info-bg px-25 py-20 text-white" style="display: none">'
            <div class="mb-10">战斗回合数 <input type="text" class="game-input text-center" style="width:100px;" name="f_count" value="${f_count}"  maxlength="2"> (最大${f_count})，<br>
                HP低于 <input type="text"  style="width:100px;" class="game-input  text-center"  name="escape_hp" value="${f_escape_hp}" maxlength="2"> %逃离战斗</div>
            <div class="mb-10">HP低于 <input type="text" style="width:100px;" class="game-input  text-center" name="f_hp" value="${f_hp}" maxlength="2"> %，
                SP低于 <input type="text"  style="width:100px;" class="game-input  text-center" name="f_sp" value="${f_sp}" maxlength="2"> %自动使用恢复道具 </div>
            <div class="mb-10">HP低于 <input type="text" style="width:100px;" class="game-input  text-center" name="hotel_hp"  value="${hotel_hp}" maxlength="2"> % ，
                SP低于 <input type="text"  style="width:100px;" class="game-input  text-center" name="hotel_sp" value="${hotel_sp}" maxlength="2"> %自动住宿(-1表示略过条件)</div>
            <div>必杀技名称 <input type="text" name="sat_name" class="game-input  text-center" value="${p_sat_name}"></div>
        </div>
    </div>
</div></form>`);
    p_c();
    // 设定快速战斗为默认选中
    setTimeout(function () {
        console.log(document.wog_view.f1)
        document.wog_view.f1.a_mode[0].checked = true;
    }, 10)
    var temp_s = Gookie("wog_set_cookie");
    if (temp_s != null) {
        var s1 = temp_s.split(",");
        var form = parent.wog_view.document.forms[0];
        switch (s1[0]) {
            case '0':
                fire_set_type(0);
                parent.select_area(s1[3], form);
                form.act_area.value = s1[3];
                form.act1.value = s1[1];
                setSubplace(form.act1.value, '');
                // form.subplace.value = s1[4];
                break;
            case '1':
                fire_set_type(1);
                form.act2.value = s1[1];
                break;
            case '2':
                fire_set_type(2);
                form.act3.value = s1[1];
//				setSubplace(form.act3.value,form.sp_subplace);
//				form.sp_subplace.value=s1[4];
                break;
        }
        if (s1[2] == 1) {
            form.a_mode[0].checked = true;
            form.a_mode[1].checked = false;
        } else {
            form.a_mode[0].checked = false;
            form.a_mode[1].checked = true;
        }
    }
};

/**
 * 自动战斗
 */
AUTO_FIGHT_TIMER = null;

function autoFight() {
    const i = 4000;
    if (!AUTO_FIGHT || AUTO_FIGHT === 'ready') {
        AUTO_FIGHT = 'start';
        AUTO_FIGHT_TIMER = setTimeout(() => {
            autoFight();
        }, i);
        return;
    }
    if (AUTO_FIGHT_TIMER) {
        clearTimeout(AUTO_FIGHT_TIMER);
        AUTO_FIGHT_TIMER = null;
    }
    console.log(AUTO_FIGHT)
    if (AUTO_FIGHT === 'start') {
        fight_fast();
        AUTO_FIGHT_TIMER = setTimeout(() => {
            autoFight();
        }, i);
    }
}

function fire_set_type(a) {
    f.f1.a_type[0].checked = false;
    f.f1.a_type[1].checked = false;
    f.f1.a_type[2].checked = false;
    f.f1.a_type[a].checked = true;
};

function fire_date(p_at, p_df, p_mat, p_mdf, p_hp, p_hpmax, p_s, p_img_set, i_img, m_at, m_df, m_mat, m_mdf, m_hp, m_hpmax, m_s, m_name, m_img, f_status) {
    var temp_s = Gookie("wog_set_cookie");
    var bg_imgs = temp_s.split(",");
    var fight_background = bg_img[bg_imgs[1]];
    var p_name = get_name();
    temp_p_hp = p_hp;
    temp_p_hpmax = p_hpmax;
    temp_m_hp = m_hp;
    temp_m_hpmax = m_hpmax;
    var temp_php_img = (temp_p_hp / temp_p_hpmax) * 100;
    var temp_mhp_img = (temp_m_hp / temp_m_hpmax) * 100;
    console.log('temp_p_hp', temp_p_hp)
    console.log('temp_m_hp', temp_m_hp)
    var p_img = "";
    var php_message = temp_p_hp + "/" + temp_p_hpmax;
    var mhp_message = temp_m_hp + "/" + temp_m_hpmax;
    setup_mname(m_name);

    p_s = s_status[p_s];
    m_s = s_status[m_s];
    if (m_img == "") {
        m_img = "no_img.jpg";
    }
    if (f_status == 1) {
        if (m_img.indexOf("http") == -1) {
            m_img = img + m_img + ".gif";
        }
        m_img = '<img id="g2" src="' + m_img + '" border="0">';
    } else {
        m_img = mimg + m_img;
        m_img = '<img id="g2" src="' + m_img + '" border="0">';
    }
    // 战斗形象，根据形象加战斗形象前缀
    // 头像
    let avatar = ''
    if (p_img_set == 1) {
        p_img = 'b' + i_img;
        avatar = 'a' + i_img;
    } else {
        p_img = img + 'b' + i_img + ".gif";
        avatar = img + 'a' + i_img + '.gif';
    }
    if (p_support_name !== "") {
        if (p_support_img.indexOf("http") === -1) {
            p_support_img = img + p_support_img + '.gif';
        }
    }
    w_c(`<div class="fighting-box p-15" style="background-image: url(${fight_background})"><div class="avg avg-2 fighting-info pt-10">
        <div class="avg-item pr-20">
        <div class="d-flex align-items-start">
        <div class="fighting-avatar"><img style="width:60px;height:40px;" src="${avatar}" alt=""></div>
        <div class="flex-1 width-0 fighting-base pl-10 text-white">
            <div class=" font-weight-bold">${p_name} (${p_s})</div>
            <div class="d-flex align-items-center"><div class="mr-5">HP</div><div class="hp flex-1"><div  class="hp-value" id="p_hp_bar" style="width:${temp_php_img}%;"></div></div><div class="ml-5" id="p_hp_text">${php_message}</div></div>
            <div class="overflow-hidden">
                <div class="avg avg-2 mt-5 mx-3-reverse">
                    <div class="avg-item px-3">
                        <div class="status-view-data"><div class="status-view-data-label min">物攻</div><div class="status-view-data-value flex-1 width-0">${p_at}</div></div>
                        </div>
                    <div class="avg-item px-3">
                        <div class="status-view-data"><div class="status-view-data-label min">魔攻</div><div class="status-view-data-value flex-1 width-0">${p_mat}</div></div>
                    </div>
                    <div class="avg-item px-3">
                        <div class="status-view-data"><div class="status-view-data-label min">物防</div><div class="status-view-data-value flex-1 width-0">${p_df}</div></div>
                        </div>
                    <div class="avg-item px-3">
                        <div class="status-view-data"><div class="status-view-data-label min">魔防</div><div class="status-view-data-value flex-1 width-0">${p_mdf}</div></div>
                    </div>
                </div>
            </div>
        </div>
        </div>
        </div>
        <div class="avg-item pl-20">
            <div class="d-flex align-items-start">
<!--            <div class="fighting-avatar"><img style="width:60px;height:40px;" src="${avatar}" alt=""></div>-->
            <div class="flex-1 width-0 fighting-base pl-10 text-white">
                <div class=" font-weight-bold">${m_name} (${m_s})</div>
                <div class="d-flex align-items-center"><div class="mr-5">HP</div><div class="hp flex-1"><div class="hp-value" id="m_hp_bar" style="width:${temp_mhp_img}%;"></div></div><div class="ml-5" id="m_hp_text">${mhp_message}</div></div>
<!--                <div class="b1"><img src="${img}bar/bhg.gif" border="0" width="260" id="m_img"  height="9" alt="${mhp_message}"></div>-->
                <div class="overflow-hidden">
                    <div class="avg avg-2 mt-5 mx-3-reverse">
                        <div class="avg-item px-3">
                            <div class="status-view-data"><div class="status-view-data-label min">物攻</div><div class="status-view-data-value flex-1 width-0">${m_at}</div></div>
                            </div>
                        <div class="avg-item px-3">
                            <div class="status-view-data"><div class="status-view-data-label min">魔攻</div><div class="status-view-data-value flex-1 width-0">${m_mat}</div></div>
                        </div>
                        <div class="avg-item px-3">
                            <div class="status-view-data"><div class="status-view-data-label min">物防</div><div class="status-view-data-value flex-1 width-0">${m_df}</div></div>
                            </div>
                        <div class="avg-item px-3">
                            <div class="status-view-data"><div class="status-view-data-label min">魔防</div><div class="status-view-data-value flex-1 width-0">${m_mdf}</div></div>
                        </div>
                    </div>
                </div>
            </div>
            </div>
        </div>
        </div>
        <div class="d-flex align-items-stretch fighting-other pt-20">
<div class="flex-1 d-flex align-items-end justify-content-center pos-r">
<div id="a1" class="pos-a top-left-0 z-index-1 fighting-skill-message p-10 full-width"></div>
<img id="g1" src="${p_img}">
<img id="g3">
${p_support_name && p_support_img ? '<img id="g4" src="' + p_support_img + '">' : ''}
</div>
<div class="fighting-log font-size-14 text-wrap text-white">

<div class="text-center pos-r" id="a4"></div>
</div>
<div class="flex-1 d-flex align-items-end justify-content-center">
${m_img}
</div>
</div></div>`);
    p_c();
};

function set_fight(temp_fightrow) {
    fight_num = 0;
    fight_count_num = 0;
    fight_message_skill = "";
    fight_message_title = "";
    fight_message = "";
    fightrow = temp_fightrow;
    parent.show_fightrow();
};

function show_fightrow() {
    if (f.getElementById("a1")) {
        for (var i = fight_num; i < fightrow.length; i++) {
            if (i === 0) {
                f.getElementById("a1").innerHTML = fightrow[i];
            } else {
                if (fightrow[i].substring(0, 9) === "parent.vc") {
                    fight_num++;
                    eval(fightrow[i]);
                    window.setTimeout("show_fightrow()", 1000);
                    break;
                }
                eval(fightrow[i]);
            }
            fight_num++;
        }
    }
};

function pact_date(temp_d, s, ss, support) {
    m_hp_status(-temp_d);
    if (support == 0) {
        f.getElementById("g1").style.visibility = "visible";
        if (f.getElementById("g3") != null) {
            f.getElementById("g3").style.visibility = "hidden";
        }
        if (f.getElementById("g4") != null) {
            f.getElementById("g4").style.visibility = "hidden";
        }
        view_fight(temp_d, s, ss, p_name, m_name);
    } else {
        f.getElementById("g1").style.visibility = "hidden";
        f.getElementById("g3").style.visibility = "hidden";
        f.getElementById("g4").style.visibility = "visible";
        view_fight(temp_d, s, ss, p_support_name, m_name);
    }
    gf = f.getElementById("g2").style.left;
    gf = gf.replace("%", "");
    gt = f.getElementById("g2").style.top;
    shock_num = 0;
    temp_obj = f.getElementById("g2").style;
    shock_s = s;
    shock_fight();
};

function mact_date(temp_d, s, ss) {
    p_hp_status(-temp_d);
    view_fight(temp_d, s, ss, m_name, p_name);
    gf = f.getElementById("g1").style.left;
    gf = gf.replace("%", "");
    gt = f.getElementById("g1").style.top;
    shock_num = 0;
    temp_obj = f.getElementById("g1").style;
    shock_s = s;
    shock_fight();
};

function pet_act_date(temp_d, s) {
    f.getElementById("g3").src = mimg + pet_img;
    f.getElementById("g1").style.visibility = "hidden";
    if (f.getElementById("g3") != null) {
        f.getElementById("g3").style.visibility = "visible";
    }
    if (f.getElementById("g4") != null) {
        f.getElementById("g4").style.visibility = "hidden";
    }
    m_hp_status(-temp_d);
    view_fight(temp_d, s, "", pet_pname, m_name);
    gf = f.getElementById("g2").style.left;
    gf = gf.replace("%", "");
    gt = f.getElementById("g2").style.top;
    shock_num = 0;
    temp_obj = f.getElementById("g2").style;
    shock_s = s;
    shock_fight();
};

function pet_def_date(temp_d, s, ss) {
    f.getElementById("g3").src = mimg + pet_img;
    f.getElementById("g1").style.visibility = "hidden";
    f.getElementById("g3").style.visibility = "visible";
    view_fight(temp_d, s, ss, m_name, pet_pname);
    gf = f.getElementById("g3").style.left;
    gf = gf.replace("%", "");
    gt = f.getElementById("g3").style.top;
    shock_num = 0;
    temp_obj = f.getElementById("g3").style;
    if (ss == "1") {
        fight_message = "<font color=#89C7F3>" + pet_pname + "</font> 战败";
    }
    shock_s = s;
    shock_fight();
};

function shock_fight() {
    var shock_ss = 1;
    if (f.getElementById("fight_table")) {
        if (shock_s != "") {
            shock_ss = 3;
            // f.getElementById("fight_table").style.backgroundColor = "#4d0002";
        } else {
            // f.getElementById("fight_table").style.backgroundColor = "#000000";
        }
        temp_obj.left = (parseInt(gf) + (Math.floor(Math.random() * 7 * shock_ss)));
        temp_obj.top = (parseInt(gt) + (Math.floor(Math.random() * 13 * shock_ss)));
        shock_num++;
        if (shock_num < 15) {
            window.setTimeout("shock_fight()", 30);
        } else {
            temp_obj.left = gf;
            temp_obj.top = gt;
        }
    }
};

function vc(a1) {
    if (fight_count_num > 0) {
        fight_show_message();
    }
    fight_count_num = a1;
    fight_message_skill = "";
    fight_message_title = '<h3> 第 ' + a1 + ' 回' + '</h3>';
    fight_message = "";
};

function view_fight(temp_d, s, ss, e, d) {
    temp_d = ' <font color=red><b>' + temp_d + '<b></font>';
    (e == p_name) ? e = '<font color="#89C7F3">' + e + '</font>' : e = '<font color="#81D8A8">' + e + '</font>';
    (d == p_name) ? d = '<font color="#89C7F3">' + d + '</font>' : d = '<font color="#81D8A8">' + d + '</font>';
    if (ss != "") {
        ss = '<img src="' + img + 'ss.gif" border="0">';
    }
    if (s != "") {
        fight_message += ss + e + ' 发动 <b><font color="#FF0000" size="+2">' + s + '</b></font> 给予 ' + d + temp_d + ' 点伤害<br>';
    } else {
        fight_message += ss + e + ' 给予 ' + d + temp_d + ' 伤害<br>';
    }
};

function miss_date(a, d) {
    (a == p_name) ? a = '<font color="#89C7F3">' + a + '</font>' : a = '<font color="#81D8A8">' + a + '</font>';
    (d == p_name) ? d = '<font color="#89C7F3">' + d + '</font>' : d = '<font color="#81D8A8">' + d + '</font>';
    fight_message += a + ' 展开攻击 ' + d + ' 快速闪开攻击<br>';
};

/**
 * 战斗结束
 * @param s
 * @param en
 * @param getexp
 * @param getmoney
 * @param p_hp
 * @param sum
 * @param d_item_num
 */
function end_date(s, en, getexp, getmoney, p_hp, sum, d_item_num) {
    var enstr = "";
    if (en == "0") {
        enstr = '<img src="./../ex_img/wog_infinity/fight/fight_lost.png" style="height:70px;" alt="战败！">';
    } else if (en == "1") {
        enstr = '<img src="./../ex_img/wog_infinity/fight/fight_win.png" style="height:70px;" alt="胜利！">';
    }
    var temp_str = '';
    temp_str += `<div class="text-center">${enstr} <br> <strong class="text-prompt font-size-20">${s}</strong></div>`
    temp_str += '<table class="fight-end-result">';
    temp_str += '<tr><td class="text-center"><b>HP剩下 ' + p_hp + ',获得经验值 ' + getexp + '<br>获得金钱 ' + getmoney + '<br>费时 ' + sum + ' 回合</b></td></tr>';
    if (d_item_num > 0) {
        var s_num = d_item2_name.lastIndexOf("*");
        if (s_num > -1) {
            d_item2_name = d_item2_name.substr(0, s_num) + "*" + d_item_num + '</a>';
        } else {
            d_item2_name += "*" + d_item_num + '</a>';
        }
        temp_str += '<tr><td><b>残余 ' + d_item2_name + '</b></td></tr>';
    }
    temp_str += '</table>';
    fight_show_message();
    f.getElementById("a4").innerHTML = temp_str;
};

function fight_show_message() {
    if (fight_message_skill.length > 0) {
        fight_message_skill = fight_message_skill.substring(0, fight_message_skill.length - 1)
    }
    f.getElementById("a1").innerHTML = fight_message_title + fight_message_skill + '<br>' + fight_message;
};

/**
 * 获得物品提示
 * @param i
 * @param s
 * @param s1
 */
function get_item(i, s, s1) {
    var enstr = "";
    if (+s === 0) {
        enstr = "装备栏超过" + s1 + "样物品无法装入";
    } else if (+s === 1) {
        enstr = "幸运捡到" + ` <strong class="fight-get-item-item">${i}</strong>`;
    }
    f.getElementById("a4").innerHTML = `<div id="fightItemResult" class="d-flex font-size-12 align-items-center justify-content-center fight-get-item-message-wrap">
<div class="fight-get-item-message">${enstr}</div>
</div>
${f.getElementById("a4").innerHTML}`;
};

function fight_event(name, s) {
    //f.getElementById("a2").style.display="block";
    //f.getElementById("a2").innerHTML=' <b>'+name+' 使用  '+s+'</b>';
    fight_message_skill += ' <b>' + name + ' 使用  ' + s + '</b> ，';
};

function fight_event2(name, temp_d, sp) {
    var temp = "";
    var temp2 = "";
    if (temp_d < 0) {
        temp = "减少";
    } else {
        temp = "增加";
    }
    if (!sp) {
        sp = 0;
    }
    if (sp < 0) {
        temp2 = "减少";
    } else {
        temp2 = "增加";
    }
    if (p_name == name) {
        p_hp_status(temp_d);
    } else {
        m_hp_status(temp_d);
    }
    //f.getElementById("a3").style.display="block";
    //f.getElementById("a3").innerHTML='<b>'+name+' HP'+temp+' '+temp_d+', SP'+temp2+' '+sp+'</b>';
    fight_message += '<b>' + name + ' HP' + temp + ' ' + temp_d + ', SP' + temp2 + ' ' + sp + '</b><br>';
};

function fight_event3(name, s) {
    fight_message += '<b>' + name + ' 使用  ' + s + '</b><br>';
};

function fight_event4(a1) {
    f.getElementById("a4").innerHTML += '<tr><td><b>' + a1 + '</b></td></tr>';
    //fight_message+='<b>'+a1+'</b><br>';
};

/**
 * 玩家血量变动
 * @param temp_d
 */
function p_hp_status(temp_d) {
    temp_p_hp = parseInt(temp_p_hp) + parseInt(temp_d);
    if (temp_p_hp < 0) {
        temp_p_hp = 0;
    }
    if (temp_p_hp > temp_p_hpmax) {
        temp_p_hp = temp_p_hpmax;
    }
    var temp_php_img = (temp_p_hp / temp_p_hpmax) * 100;
    if (f.getElementById("p_hp_bar")) {
        f.getElementById("p_hp_bar").style.width = temp_php_img + '%';
        f.getElementById("p_hp_text").innerText = temp_p_hp + "/" + temp_p_hpmax;
    }
};

/**
 * 怪物血量变动
 * @param temp_d
 */
function m_hp_status(temp_d) {
    temp_m_hp = parseInt(temp_m_hp) + parseInt(temp_d);
    if (temp_m_hp < 0) {
        temp_m_hp = 0;
    }
    if (temp_m_hp > temp_m_hpmax) {
        temp_m_hp = temp_m_hpmax;
    }
    var temp_mhp_img = (temp_m_hp / temp_m_hpmax) * 100;
    if (f.getElementById("m_hp_bar")) {
        f.getElementById("m_hp_bar").style.width = temp_mhp_img + '%';
        f.getElementById("m_hp_text").innerText = temp_m_hp + "/" + temp_m_hpmax;
    }
};

function lv_up(str, agl, smart, life, vit, au, be, up_type) {
    if (up_type == null) {
        w_c(hr);
        w_c(temp_table1 + '<tr><td><b>' + p_name + ' 等级上升 </b></td></tr>');
        str = parseInt(str);
        agl = parseInt(agl);
        smart = parseInt(smart);
        life = parseInt(life);
        vit = parseInt(vit);
        au = parseInt(au);
        be = parseInt(be);
        base_str = str, base_smart = smart, base_agi = agl, base_vit = vit, base_life = life, base_au = au, base_be = be;
        parent.lv_up2(str, agl, smart, life, vit, au, be, null);
    }
};

function lv_up2(str, agl, smart, life, vit, au, be, p_exp) {
    if (p_exp != null) {
        w_c(temp_table1 + '<tr><td class="b1"><b>' + p_name + ' 能力上升 </b></td></tr>');
        w_c('<tr><td class="b1"><b>经验值上升 ' + p_exp + '</b></td></tr>');
    }
    w_c('<tr><td><b>力量上升 ' + str + ',敏捷上升 ' + agl + ',智力上升 ' + smart + ',生命上升 ' + life + ',体质上升 ' + vit + ',魅力上升 ' + au + ',信仰上升 ' + be + '</b></td></tr>');
    w_c(temp_table2);
    p_nc();
};

function cp_end(p_name) {
    w_c(temp_table1);
    w_c('<tr><td  >' + p_name + ' 顺利当上冠军 </td></tr>')
    w_c(temp_table2);
    p_nc();
};